package test4_9.demo04;

public class Homework20_6 {

    /*
    定义一个递归方法public static int sum(int a)，用来计算a的累加和；即从1+2+…n;
     */

    public static int sum(int a){
        if (a==0){
            return 0;
        }else if(a == 1){
            return 1;
        }
        return a+sum(a-1);
    }

    public static void main(String[] args) {
        System.out.println(sum(3));
    }


}
